using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;



namespace StockPortfolio
{
   public class DigitalCheckBook : System.Windows.Forms.Form
   {
       private Button button1;
       private Button Next;
       private System.Data.SqlClient.SqlConnection objsqlConnection;
       private DateTimePicker dateTimePicker1;
       private Button update_btn;
       private Button remove_btn;
       private Button add_btn;
       private SqlCommand sqlInsertMonth;
       private Label label7;
       private Button btnCommit;
       private Label label9;
       private Label label10;
       private Label label11;
       private SqlCommand sqlGetBalance;
       private SqlConnection sqlConnectionBook;
       private Label lblBalance;
       private ComboBox comboDesc;
       private TextBox txtInDeposits;
       private TextBox txtInCredits;
       private SqlCommand sqlCommit;
       private MenuStrip menuStrip1;
       private ToolStripMenuItem fileToolStripMenuItem;
       private ToolStripMenuItem refreshToolStripMenuItem;
       private ToolStripMenuItem infoToolStripMenuItem;
       private SqlCommand sqlDelete;
       private Label lblRowCount;
       private SqlCommand sqlAllGetMyBook;
       private DataGridView dataGridView;
       private CheckBookDataSet checkBookDataSet;
       private BindingSource checkBookBindingSource;
       private IContainer components;
       private StockPortfolio.CheckBookDataSetTableAdapters.checkBookTableAdapter checkBookTableAdapter;
       private DataGridViewTextBoxColumn idRecordDataGridViewTextBoxColumn;
       private DataGridViewTextBoxColumn dateDataGridViewTextBoxColumn;
       private DataGridViewTextBoxColumn descriptionDataGridViewTextBoxColumn;
       private DataGridViewTextBoxColumn depositsDataGridViewTextBoxColumn;
       private DataGridViewTextBoxColumn creditsDataGridViewTextBoxColumn;
       private DataGridViewTextBoxColumn balanceDataGridViewTextBoxColumn;
       private ToolStripMenuItem informationToolStripMenuItem;
       private decimal totalBal;
       private PictureBox pictureBox1;
       private Button button2;
       private OpenFileDialog OpenFileDialog1;
       private ListBox listBox1;
       private ListBox listbox2;
       private CHECK newCheckBook = new CHECK();


       public DigitalCheckBook()
      {
         //
         // Required for Windows Form Designer support
         //
         InitializeComponent();

         //
         // TODO: Add any constructor code after InitializeComponent call
         //
      }

      #region Windows Form Designer generated code
      /// <summary>
      /// Required method for Designer support - do not modify
      /// the contents of this method with the code editor.
      /// </summary>
      private void InitializeComponent()
      {
         this.components = new System.ComponentModel.Container();
         this.button1 = new System.Windows.Forms.Button();
         this.Next = new System.Windows.Forms.Button();
         this.objsqlConnection = new System.Data.SqlClient.SqlConnection();
         this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
         this.update_btn = new System.Windows.Forms.Button();
         this.remove_btn = new System.Windows.Forms.Button();
         this.add_btn = new System.Windows.Forms.Button();
         this.sqlInsertMonth = new System.Data.SqlClient.SqlCommand();
         this.label7 = new System.Windows.Forms.Label();
         this.btnCommit = new System.Windows.Forms.Button();
         this.label9 = new System.Windows.Forms.Label();
         this.label10 = new System.Windows.Forms.Label();
         this.label11 = new System.Windows.Forms.Label();
         this.sqlGetBalance = new System.Data.SqlClient.SqlCommand();
         this.sqlConnectionBook = new System.Data.SqlClient.SqlConnection();
         this.lblBalance = new System.Windows.Forms.Label();
         this.comboDesc = new System.Windows.Forms.ComboBox();
         this.txtInDeposits = new System.Windows.Forms.TextBox();
         this.txtInCredits = new System.Windows.Forms.TextBox();
         this.sqlCommit = new System.Data.SqlClient.SqlCommand();
         this.menuStrip1 = new System.Windows.Forms.MenuStrip();
         this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
         this.refreshToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
         this.infoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
         this.informationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
         this.sqlDelete = new System.Data.SqlClient.SqlCommand();
         this.lblRowCount = new System.Windows.Forms.Label();
         this.sqlAllGetMyBook = new System.Data.SqlClient.SqlCommand();
         this.dataGridView = new System.Windows.Forms.DataGridView();
         this.pictureBox1 = new System.Windows.Forms.PictureBox();
         this.button2 = new System.Windows.Forms.Button();
         this.OpenFileDialog1 = new System.Windows.Forms.OpenFileDialog();
         this.listBox1 = new System.Windows.Forms.ListBox();
         this.listbox2 = new System.Windows.Forms.ListBox();
         this.idRecordDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
         this.dateDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
         this.descriptionDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
         this.depositsDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
         this.creditsDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
         this.balanceDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
         this.checkBookBindingSource = new System.Windows.Forms.BindingSource(this.components);
         this.checkBookDataSet = new StockPortfolio.CheckBookDataSet();
         this.checkBookTableAdapter = new StockPortfolio.CheckBookDataSetTableAdapters.checkBookTableAdapter();
         this.menuStrip1.SuspendLayout();
         ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
         ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
         ((System.ComponentModel.ISupportInitialize)(this.checkBookBindingSource)).BeginInit();
         ((System.ComponentModel.ISupportInitialize)(this.checkBookDataSet)).BeginInit();
         this.SuspendLayout();
         // 
         // button1
         // 
         this.button1.Location = new System.Drawing.Point(12, 423);
         this.button1.Name = "button1";
         this.button1.Size = new System.Drawing.Size(75, 23);
         this.button1.TabIndex = 6;
         this.button1.Text = "previous";
         this.button1.UseVisualStyleBackColor = true;
         this.button1.Click += new System.EventHandler(this.button1_Click);
         // 
         // Next
         // 
         this.Next.Location = new System.Drawing.Point(113, 423);
         this.Next.Name = "Next";
         this.Next.Size = new System.Drawing.Size(75, 23);
         this.Next.TabIndex = 7;
         this.Next.Text = "Graph";
         this.Next.UseVisualStyleBackColor = true;
         this.Next.Click += new System.EventHandler(this.Next_Click);
         // 
         // objsqlConnection
         // 
         this.objsqlConnection.ConnectionString = "Data Source=DIESEL\\SQLEXPRESS;Initial Catalog=Checking;Integrated Security=True";
         this.objsqlConnection.FireInfoMessageEventOnUserErrors = false;
         // 
         // dateTimePicker1
         // 
         this.dateTimePicker1.Location = new System.Drawing.Point(8, 58);
         this.dateTimePicker1.Name = "dateTimePicker1";
         this.dateTimePicker1.Size = new System.Drawing.Size(200, 21);
         this.dateTimePicker1.TabIndex = 11;
         this.dateTimePicker1.ValueChanged += new System.EventHandler(this.dateTimePicker1_ValueChanged);
         // 
         // update_btn
         // 
         this.update_btn.Location = new System.Drawing.Point(220, 422);
         this.update_btn.Name = "update_btn";
         this.update_btn.Size = new System.Drawing.Size(75, 23);
         this.update_btn.TabIndex = 12;
         this.update_btn.Text = "Update";
         this.update_btn.UseVisualStyleBackColor = true;
         this.update_btn.Click += new System.EventHandler(this.update_btn_Click);
         // 
         // remove_btn
         // 
         this.remove_btn.Location = new System.Drawing.Point(343, 422);
         this.remove_btn.Name = "remove_btn";
         this.remove_btn.Size = new System.Drawing.Size(75, 23);
         this.remove_btn.TabIndex = 13;
         this.remove_btn.Text = "Remove";
         this.remove_btn.UseVisualStyleBackColor = true;
         this.remove_btn.Click += new System.EventHandler(this.remove_btn_Click);
         // 
         // add_btn
         // 
         this.add_btn.Location = new System.Drawing.Point(435, 423);
         this.add_btn.Name = "add_btn";
         this.add_btn.Size = new System.Drawing.Size(75, 23);
         this.add_btn.TabIndex = 14;
         this.add_btn.Text = "Add";
         this.add_btn.UseVisualStyleBackColor = true;
         this.add_btn.Click += new System.EventHandler(this.add_btn_Click);
         // 
         // sqlInsertMonth
         // 
         this.sqlInsertMonth.CommandText = "INSERT INTO Date\r\n                         (Month)\r\nVALUES        (@Month)";
         this.sqlInsertMonth.Parameters.AddRange(new System.Data.SqlClient.SqlParameter[] {
            new System.Data.SqlClient.SqlParameter("@Month", System.Data.SqlDbType.NVarChar, 50, "Month")});
         // 
         // label7
         // 
         this.label7.AutoSize = true;
         this.label7.Location = new System.Drawing.Point(221, 27);
         this.label7.Name = "label7";
         this.label7.Size = new System.Drawing.Size(60, 13);
         this.label7.TabIndex = 32;
         this.label7.Text = "Description";
         // 
         // btnCommit
         // 
         this.btnCommit.Location = new System.Drawing.Point(607, 423);
         this.btnCommit.Name = "btnCommit";
         this.btnCommit.Size = new System.Drawing.Size(146, 23);
         this.btnCommit.TabIndex = 33;
         this.btnCommit.Text = "Write to check book";
         this.btnCommit.UseVisualStyleBackColor = true;
         this.btnCommit.Click += new System.EventHandler(this.btnCommit_Click);
         // 
         // label9
         // 
         this.label9.AutoSize = true;
         this.label9.Location = new System.Drawing.Point(453, 24);
         this.label9.Name = "label9";
         this.label9.Size = new System.Drawing.Size(52, 13);
         this.label9.TabIndex = 34;
         this.label9.Text = "Deposits:";
         // 
         // label10
         // 
         this.label10.AutoSize = true;
         this.label10.Location = new System.Drawing.Point(571, 24);
         this.label10.Name = "label10";
         this.label10.Size = new System.Drawing.Size(45, 13);
         this.label10.TabIndex = 35;
         this.label10.Text = "Credits:";
         // 
         // label11
         // 
         this.label11.AutoSize = true;
         this.label11.Location = new System.Drawing.Point(683, 24);
         this.label11.Name = "label11";
         this.label11.Size = new System.Drawing.Size(48, 13);
         this.label11.TabIndex = 36;
         this.label11.Text = "Balance:";
         // 
         // sqlGetBalance
         // 
         this.sqlGetBalance.CommandText = "SELECT        Balance\r\nFROM            checkBook";
         this.sqlGetBalance.Connection = this.sqlConnectionBook;
         // 
         // sqlConnectionBook
         // 
         this.sqlConnectionBook.ConnectionString = "Data Source=NEWBOLDPWDEV3;Initial Catalog=Checking;Integrated Security=True";
         this.sqlConnectionBook.FireInfoMessageEventOnUserErrors = false;
         this.sqlConnectionBook.InfoMessage += new System.Data.SqlClient.SqlInfoMessageEventHandler(this.sqlConnection2_InfoMessage);
         // 
         // lblBalance
         // 
         this.lblBalance.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
         this.lblBalance.AutoEllipsis = true;
         this.lblBalance.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
         this.lblBalance.Location = new System.Drawing.Point(683, 54);
         this.lblBalance.Margin = new System.Windows.Forms.Padding(0);
         this.lblBalance.MaximumSize = new System.Drawing.Size(100, 100);
         this.lblBalance.MinimumSize = new System.Drawing.Size(5, 5);
         this.lblBalance.Name = "lblBalance";
         this.lblBalance.Size = new System.Drawing.Size(93, 28);
         this.lblBalance.TabIndex = 37;
         this.lblBalance.Click += new System.EventHandler(this.lblBalance_Click);
         // 
         // comboDesc
         // 
         this.comboDesc.FormattingEnabled = true;
         this.comboDesc.Items.AddRange(new object[] {
            "Rent",
            "Car",
            "School",
            "Electricity",
            "Gas",
            "Credit Card",
            "Other"});
         this.comboDesc.Location = new System.Drawing.Point(224, 58);
         this.comboDesc.Name = "comboDesc";
         this.comboDesc.Size = new System.Drawing.Size(219, 21);
         this.comboDesc.TabIndex = 38;
         // 
         // txtInDeposits
         // 
         this.txtInDeposits.Location = new System.Drawing.Point(456, 55);
         this.txtInDeposits.Name = "txtInDeposits";
         this.txtInDeposits.Size = new System.Drawing.Size(79, 21);
         this.txtInDeposits.TabIndex = 39;
         // 
         // txtInCredits
         // 
         this.txtInCredits.Location = new System.Drawing.Point(558, 53);
         this.txtInCredits.Name = "txtInCredits";
         this.txtInCredits.Size = new System.Drawing.Size(79, 21);
         this.txtInCredits.TabIndex = 40;
         // 
         // sqlCommit
         // 
         this.sqlCommit.CommandText = "INSERT INTO checkBook\r\n                         (Date, Description, Deposits, Cre" +
             "dits, Balance)\r\nVALUES        (@Date,@Desc,@Deposits,@Credits,@Balance)";
         this.sqlCommit.Connection = this.sqlConnectionBook;
         this.sqlCommit.Parameters.AddRange(new System.Data.SqlClient.SqlParameter[] {
            new System.Data.SqlClient.SqlParameter("@Date", System.Data.SqlDbType.VarChar, 50, "Date"),
            new System.Data.SqlClient.SqlParameter("@Desc", System.Data.SqlDbType.NVarChar, 50, "Description"),
            new System.Data.SqlClient.SqlParameter("@Deposits", System.Data.SqlDbType.Decimal, 9, System.Data.ParameterDirection.Input, false, ((byte)(18)), ((byte)(0)), "Deposits", System.Data.DataRowVersion.Current, null),
            new System.Data.SqlClient.SqlParameter("@Credits", System.Data.SqlDbType.Decimal, 9, System.Data.ParameterDirection.Input, false, ((byte)(18)), ((byte)(0)), "Credits", System.Data.DataRowVersion.Current, null),
            new System.Data.SqlClient.SqlParameter("@Balance", System.Data.SqlDbType.Decimal, 9, System.Data.ParameterDirection.Input, false, ((byte)(18)), ((byte)(0)), "Balance", System.Data.DataRowVersion.Current, null)});
         // 
         // menuStrip1
         // 
         this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.fileToolStripMenuItem,
            this.infoToolStripMenuItem});
         this.menuStrip1.Location = new System.Drawing.Point(0, 0);
         this.menuStrip1.Name = "menuStrip1";
         this.menuStrip1.Size = new System.Drawing.Size(1020, 24);
         this.menuStrip1.TabIndex = 42;
         this.menuStrip1.Text = "menuStrip1";
         // 
         // fileToolStripMenuItem
         // 
         this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.refreshToolStripMenuItem});
         this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
         this.fileToolStripMenuItem.Size = new System.Drawing.Size(35, 20);
         this.fileToolStripMenuItem.Text = "File";
         // 
         // refreshToolStripMenuItem
         // 
         this.refreshToolStripMenuItem.Name = "refreshToolStripMenuItem";
         this.refreshToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
         this.refreshToolStripMenuItem.Text = "Refresh";
         this.refreshToolStripMenuItem.Click += new System.EventHandler(this.refreshToolStripMenuItem_Click_1);
         // 
         // infoToolStripMenuItem
         // 
         this.infoToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.informationToolStripMenuItem});
         this.infoToolStripMenuItem.Name = "infoToolStripMenuItem";
         this.infoToolStripMenuItem.Size = new System.Drawing.Size(39, 20);
         this.infoToolStripMenuItem.Text = "Info";
         // 
         // informationToolStripMenuItem
         // 
         this.informationToolStripMenuItem.Name = "informationToolStripMenuItem";
         this.informationToolStripMenuItem.Size = new System.Drawing.Size(141, 22);
         this.informationToolStripMenuItem.Text = "Information";
         this.informationToolStripMenuItem.Click += new System.EventHandler(this.informationToolStripMenuItem_Click);
         // 
         // sqlDelete
         // 
         this.sqlDelete.CommandText = "DELETE FROM checkBook\r\nWHERE        (idRecord = @idRecord)";
         this.sqlDelete.Connection = this.sqlConnectionBook;
         this.sqlDelete.Parameters.AddRange(new System.Data.SqlClient.SqlParameter[] {
            new System.Data.SqlClient.SqlParameter("@idRecord", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "idRecord", System.Data.DataRowVersion.Original, null)});
         // 
         // lblRowCount
         // 
         this.lblRowCount.Location = new System.Drawing.Point(37, 479);
         this.lblRowCount.Name = "lblRowCount";
         this.lblRowCount.Size = new System.Drawing.Size(171, 72);
         this.lblRowCount.TabIndex = 43;
         this.lblRowCount.Text = "label1";
         // 
         // sqlAllGetMyBook
         // 
         this.sqlAllGetMyBook.CommandText = "SELECT        idRecord, Date, Description, Deposits, Credits, Balance\r\nFROM      " +
             "      checkBook\r\nORDER BY Date DESC";
         this.sqlAllGetMyBook.Connection = this.sqlConnectionBook;
         // 
         // dataGridView
         // 
         this.dataGridView.AllowUserToOrderColumns = true;
         this.dataGridView.AutoGenerateColumns = false;
         this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
         this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.idRecordDataGridViewTextBoxColumn,
            this.dateDataGridViewTextBoxColumn,
            this.descriptionDataGridViewTextBoxColumn,
            this.depositsDataGridViewTextBoxColumn,
            this.creditsDataGridViewTextBoxColumn,
            this.balanceDataGridViewTextBoxColumn});
         this.dataGridView.DataSource = this.checkBookBindingSource;
         this.dataGridView.Location = new System.Drawing.Point(8, 85);
         this.dataGridView.Name = "dataGridView";
         this.dataGridView.Size = new System.Drawing.Size(745, 331);
         this.dataGridView.TabIndex = 44;
         // 
         // pictureBox1
         // 
         this.pictureBox1.Location = new System.Drawing.Point(777, 85);
         this.pictureBox1.Name = "pictureBox1";
         this.pictureBox1.Size = new System.Drawing.Size(231, 238);
         this.pictureBox1.TabIndex = 45;
         this.pictureBox1.TabStop = false;
         // 
         // button2
         // 
         this.button2.Location = new System.Drawing.Point(856, 340);
         this.button2.Name = "button2";
         this.button2.Size = new System.Drawing.Size(114, 23);
         this.button2.TabIndex = 46;
         this.button2.Text = "Select Image";
         this.button2.UseVisualStyleBackColor = true;
         this.button2.Click += new System.EventHandler(this.button2_Click);
         // 
         // OpenFileDialog1
         // 
         this.OpenFileDialog1.FileName = "OpenFileDialog1";
         // 
         // listBox1
         // 
         this.listBox1.FormattingEnabled = true;
         this.listBox1.Location = new System.Drawing.Point(777, 388);
         this.listBox1.Name = "listBox1";
         this.listBox1.Size = new System.Drawing.Size(211, 147);
         this.listBox1.TabIndex = 47;
         // 
         // listbox2
         // 
         this.listbox2.FormattingEnabled = true;
         this.listbox2.Location = new System.Drawing.Point(187, 451);
         this.listbox2.Name = "listbox2";
         this.listbox2.Size = new System.Drawing.Size(551, 121);
         this.listbox2.TabIndex = 48;
         // 
         // idRecordDataGridViewTextBoxColumn
         // 
         this.idRecordDataGridViewTextBoxColumn.DataPropertyName = "idRecord";
         this.idRecordDataGridViewTextBoxColumn.HeaderText = "idRecord";
         this.idRecordDataGridViewTextBoxColumn.Name = "idRecordDataGridViewTextBoxColumn";
         this.idRecordDataGridViewTextBoxColumn.ReadOnly = true;
         this.idRecordDataGridViewTextBoxColumn.Visible = false;
         // 
         // dateDataGridViewTextBoxColumn
         // 
         this.dateDataGridViewTextBoxColumn.DataPropertyName = "Date";
         this.dateDataGridViewTextBoxColumn.HeaderText = "Date";
         this.dateDataGridViewTextBoxColumn.Name = "dateDataGridViewTextBoxColumn";
         this.dateDataGridViewTextBoxColumn.Width = 150;
         // 
         // descriptionDataGridViewTextBoxColumn
         // 
         this.descriptionDataGridViewTextBoxColumn.DataPropertyName = "Description";
         this.descriptionDataGridViewTextBoxColumn.HeaderText = "Description";
         this.descriptionDataGridViewTextBoxColumn.Name = "descriptionDataGridViewTextBoxColumn";
         this.descriptionDataGridViewTextBoxColumn.Width = 250;
         // 
         // depositsDataGridViewTextBoxColumn
         // 
         this.depositsDataGridViewTextBoxColumn.DataPropertyName = "Deposits";
         this.depositsDataGridViewTextBoxColumn.HeaderText = "Deposits";
         this.depositsDataGridViewTextBoxColumn.Name = "depositsDataGridViewTextBoxColumn";
         // 
         // creditsDataGridViewTextBoxColumn
         // 
         this.creditsDataGridViewTextBoxColumn.DataPropertyName = "Credits";
         this.creditsDataGridViewTextBoxColumn.HeaderText = "Credits";
         this.creditsDataGridViewTextBoxColumn.Name = "creditsDataGridViewTextBoxColumn";
         // 
         // balanceDataGridViewTextBoxColumn
         // 
         this.balanceDataGridViewTextBoxColumn.DataPropertyName = "Balance";
         this.balanceDataGridViewTextBoxColumn.HeaderText = "Balance";
         this.balanceDataGridViewTextBoxColumn.Name = "balanceDataGridViewTextBoxColumn";
         // 
         // checkBookBindingSource
         // 
         this.checkBookBindingSource.DataMember = "checkBook";
         this.checkBookBindingSource.DataSource = this.checkBookDataSet;
         // 
         // checkBookDataSet
         // 
         this.checkBookDataSet.DataSetName = "CheckBookDataSet";
         this.checkBookDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
         // 
         // checkBookTableAdapter
         // 
         this.checkBookTableAdapter.ClearBeforeFill = true;
         // 
         // DigitalCheckBook
         // 
         this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
         this.ClientSize = new System.Drawing.Size(1020, 584);
         this.Controls.Add(this.listbox2);
         this.Controls.Add(this.listBox1);
         this.Controls.Add(this.button2);
         this.Controls.Add(this.pictureBox1);
         this.Controls.Add(this.dataGridView);
         this.Controls.Add(this.lblRowCount);
         this.Controls.Add(this.txtInCredits);
         this.Controls.Add(this.txtInDeposits);
         this.Controls.Add(this.comboDesc);
         this.Controls.Add(this.lblBalance);
         this.Controls.Add(this.label11);
         this.Controls.Add(this.label10);
         this.Controls.Add(this.label9);
         this.Controls.Add(this.btnCommit);
         this.Controls.Add(this.label7);
         this.Controls.Add(this.add_btn);
         this.Controls.Add(this.remove_btn);
         this.Controls.Add(this.update_btn);
         this.Controls.Add(this.dateTimePicker1);
         this.Controls.Add(this.Next);
         this.Controls.Add(this.button1);
         this.Controls.Add(this.menuStrip1);
         this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
         this.MainMenuStrip = this.menuStrip1;
         this.Name = "DigitalCheckBook";
         this.Text = "sql";
         this.Load += new System.EventHandler(this.FrmStockPortfolio_Load);
         this.menuStrip1.ResumeLayout(false);
         this.menuStrip1.PerformLayout();
         ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
         ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
         ((System.ComponentModel.ISupportInitialize)(this.checkBookBindingSource)).EndInit();
         ((System.ComponentModel.ISupportInitialize)(this.checkBookDataSet)).EndInit();
         this.ResumeLayout(false);
         this.PerformLayout();

      }
      #endregion

      /// <summary>
      /// The main entry point for the application.
      /// </summary>
      [STAThread]
      static void Main() 
      {
          Application.Run(new DigitalCheckBook());
      }

     // // helper method to compute total value of stock
     ////  and return it as a string
     // private string ComputeTotalValueString( 
     //    string strShareNumber, string strSharePrice )
     // {
     //    int intShareNumber = Int32.Parse( strShareNumber );
     //    decimal decSharePrice = Decimal.Parse( strSharePrice );

     //    // return the total value formatted as a currency
     //    return String.Format( "{0:C}",
     //       ( intShareNumber * decSharePrice ) );
      
     // }

         

       private void FrmStockPortfolio_Load(object sender, EventArgs e)
       {
           
        
           lblRowCount.Visible = false;
           // TODO: This line of code loads data into the 'checkBookDataSet.checkBook' table. You can move, or remove it, as needed.
           this.checkBookBindingSource.Sort = "idRecord ASC";
           dataGridView.Update();
           this.checkBookTableAdapter.Fill(this.checkBookDataSet.checkBook);
           this.dataGridView.Refresh();
          // CHECK newCheckBook = new CHECK();   
           sqlConnectionBook.Open();
           SqlDataReader objGetDataBalance = sqlGetBalance.ExecuteReader();

           while (objGetDataBalance.Read())
           {
             //  newCheckBook.CRED = Convert.ToDecimal(objGetDataBalance["Credits"]);
              //lblBalance.Text = String.Format("{0:C}",(objGetDataBalance["Balance"]));
              // lblRowCount.Text = String.Format("{0:C}", (objGetDataBalance["Balance"]));
              newCheckBook.BAL = Convert.ToDecimal(objGetDataBalance["Balance"]);
              lblBalance.Text = newCheckBook.BAL.ToString();
              //lblRowCount.Text = newCheckBook.BAL.ToString();
              totalBal = newCheckBook.BAL;
           }
          
           objGetDataBalance.Close();
           sqlConnectionBook.Close();
           this.Paint += new PaintEventHandler(DigitalCheckBook_Paint);
          
         
       }

       void DigitalCheckBook_Paint(object sender, PaintEventArgs e)
       {
          //throw new NotImplementedException();
         
        
          //base.OnPaint(e);
          string[] myMonths = new string[checkBookDataSet.checkBook.Rows.Count];

          for (int i = 0; i < myMonths.Length; i++)
          {
             DataRow myData = checkBookDataSet.checkBook[i];
             lblRowCount.Visible = true;
             lblRowCount.Text = myData["Date"].ToString() + " " + "This is the row count  " + checkBookDataSet.checkBook.Rows.Count;
             string[] dates = { myData["Date"].ToString() };
             listBox1.Items.Add(myData["Balance"].ToString() + " This is the balance");
             listbox2.Items.Add(myData["Date"].ToString() + " This is the date");
             int convertMonth;
             if (myData["Date"].ToString().Contains("February"))
             {
                convertMonth = 2;
             }
             else
             {
                convertMonth = 99;
             }
             listbox2.Items.Add(convertMonth.ToString() + " this is the numeric value for the month");
             Point graphPt = new Point(convertMonth, Convert.ToInt32(myData["Balance"]));
             listbox2.Items.Add(graphPt + " This is the graph point");
             Graphics drwGraph1 = e.Graphics;

             Pen GoldPen = new Pen(Color.Gold, 3);
             drwGraph1.DrawRectangle(GoldPen, 0, 0, 600, 250);
             Point home = new Point(5, 50);
             Point month = new Point();
             Point month2 = new Point(150, 100);
             month.X = 100;
             month.Y = 150;
             //drwGraph1.DrawLine(GoldPen, graphPt.X,graphPt.Y);
             drwGraph1.DrawLine(GoldPen, month, month2);

             // Point[] ptArr = new Point[]{new Point(convertMonth,Convert.ToInt32(myData["Balance"]))};
             //Point[] ptArr = new Point[]{[checkBookDataSet.checkBook.Rows.Count];
       
          }
      
          // drwGraph1.DrawLine (new Pen(Color.Red, 2), 5,5, 5,250);
          // drwGraph1.DrawLine(new Pen(Color.Red, 2), 5, 250, 300, 250); 
        
       }
   
       private void btnStockInformation_Click(object sender, EventArgs e)
       {
          
       }

       private void Next_Click(object sender, EventArgs e)
       {

           frmGraph graph = new frmGraph();
           graph.Show();


       }

       private void txtsym_Click(object sender, EventArgs e)
       {
           //  //// conn and reader declared outside try
           //  ////// block for visibility in finally block
           //  //SqlConnection conn   = null;
           //  //SqlDataReader reader = null;



           //  decimal gotIt;
           //  string Entered;

           //  //Open the sql connection

           //  // don't ever do this!
           //  //			SqlCommand cmd = new SqlCommand(
           //  //				"select * from Customers where city = '" + inputCity + "'";


           //    // 1. declare command object with parameter
           //     //I did did this  by creating a sq; command called sqlAddrecord
           //  ////create the reader
           //  //SqlDataReader objGetData = objsqlCommandgetnames.ExecuteReader();

           //  ////Read the data 
           //  //objGetData.Read();




           //  // 2. define parameters used in command object
           //  SqlParameter param  = new SqlParameter();
           //  param.ParameterName = "@Rent";
           //  param.Value         = inputCity;

           //  // 3. add new parameter to command object
           //  //sqlAddRecord.Parameters.Add(param);
           //  sqlUpdate.Parameters.Add(param);
           //  sqlUpdate.ExecuteNonQuery();

           // //sqlAddRecord.Parameters.Add("@Rent", inputCity);
           //  //objGetData.Close();
           //  objsqlConnection.Close();


           // //show the new value at rent
           //  MessageBox.Show(param.ParameterName.ToString() + param.Value.ToString());
           // Entered = txttotal.Text;

           // gotIt = Convert.ToDecimal(Entered);

           // //Add record


           ////sqlAddRecord.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord;
           ////sqlAddRecord.Parameters.Add(Convert.ToInt32(inputCity));



           //// sqlAddRecord.Parameters["Car"].Value = "14";
           //// sqlAddRecord.Parameters["School"].Value = "50.00";
           //// sqlAddRecord.Parameters["Electricity"].Value = "30.00";
           //// sqlAddRecord.Parameters["Gas"].Value = "11";
           ////// sqlAddRecord.Parameters    Value = gotIt;

           ////sqlAddRecord.ExecuteNonQuery();

           //objsqlConnection.Close();

       }

       private void txtshare_Click(object sender, EventArgs e)
       {

       }

       private void add_btn_Click(object sender, EventArgs e)
       {
/*
           string desc;
           string deposit = "";
           string credit = "";
           string bal = "";
           string date;
           date = dateTimePicker1.Text;
           desc = comboDesc.Text;
           deposit = txtInDeposits.Text;
           credit = txtInCredits.Text;
           bal = GETBALANCE(deposit, credit);
 

           sqlCommit.Parameters["@Deposits"].Value = deposit;
           sqlCommit.Parameters["@Credits"].Value = credit;
           sqlCommit.Parameters["@Desc"].Value = desc;
           sqlCommit.Parameters["@Date"].Value = date;
           sqlCommit.Parameters["@Balance"].Value = bal;

           objsqlConnection.Open();
           sqlCommit.ExecuteNonQuery();
           objsqlConnection.Close();



           
           sqlAddRecord.Parameters["@Rent"].Value = txtRentIn.Text;
           sqlAddRecord.Parameters["@Car"].Value = txtInCar.Text;
           sqlAddRecord.Parameters["@Gas"].Value = textInGas.Text;
           sqlAddRecord.Parameters["@School"].Value = textInSchool.Text;
           sqlAddRecord.Parameters["@Elec"].Value = textInElec.Text;
           sqlAddRecord.Parameters["@CC"].Value =  textInCC.Text;

           objsqlConnection.Open();
           sqlAddRecord.ExecuteNonQuery();
           objsqlConnection.Close();
         

       */            
           
       }


     
       //Private Function that returns a random number
       private int getrandom(int Min, int Max)
       {
           Random random = new Random();
           return random.Next(Min, Max);
       }
            



    private void remove_btn_Click(object sender, EventArgs e)
       {

            
            
           //sqlConnectionBook.Open();
           //sqlDelete.ExecuteNonQuery();
           //sqlConnectionBook.Close();


           //dataGridView1.Refresh();
           //dataGridView1.Parent.Refresh();
           //////int number = getrandom(3,10);
           ////txtRent.Text = number.ToString();



           //dataGridView1.EndEdit();

           //dataGridView1.Refresh();
           //dataGridView1.Parent.Refresh();
         
       }
       
       
       private void update_btn_Click(object sender, EventArgs e)
       {
           ////works finally 2-2-09
           ////decimal gotIt;
           ////string Entered;
           ////Set the value in commit textbox to rent column         
           //string inputRent = txtRentIn.Text;
           //string inputCar = txtInCar.Text;
           //string inputGas = textInGas.Text;
           //string inputSch = textInSchool.Text;
           //string inputEL = textInElec.Text;
           //string inputCC = textInCC.Text;
           //sqlUpdate.Parameters["@Rent"].Value = inputRent;
           //sqlUpdate.Parameters["@Car"].Value = inputCar;
           //sqlUpdate.Parameters["@Gas"].Value = inputGas;
           //sqlUpdate.Parameters["@SCH"].Value = inputSch;
           //sqlUpdate.Parameters["@EL"].Value = inputEL;
           //sqlUpdate.Parameters["@CC"].Value = inputCC;
           //objsqlConnection.Open();
           //sqlUpdate.ExecuteNonQuery();
           //objsqlConnection.Close();
           ////Entered = txttotal.Text;
           ////gotIt = Convert.ToDecimal(Entered);
           ////txtRentIn.Text = Convert.ToString(gotIt);



       }

       private void bindingNavigator1_RefreshItems(object sender, EventArgs e)
       {
          
           
        

       }

       private void txtRentIn_TextChanged(object sender, EventArgs e)
       {
          
           //claer the tex totl box
          // txttotal.Text = "";

         
       }

       private void button1_Click(object sender, EventArgs e)
       {
        
         
       }

       private void refreshToolStripMenuItem_Click(object sender, EventArgs e)
       {
           Application.Restart();
       }

       private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
       {
           //string date;
           //date = dateTimePicker1.Text;
           //MessageBox.Show(date);
           //sqlInsertMonth.Parameters["@Month"].Value = date;
           //sqlConnection1.Open();
           //sqlInsertMonth.ExecuteNonQuery();
           //sqlConnection1.Close();


       }

       private void sqlConnection2_InfoMessage(object sender, SqlInfoMessageEventArgs e)
       {

       }
       
       private void btnCommit_Click(object sender, EventArgs e)
       {
          
           string desc;
           decimal deposit;
           decimal credit;
           string date;
           if (txtInDeposits.Text == "")
           {
               txtInDeposits.Text = "0";
           }
           if (txtInCredits.Text == "")
           {
               txtInCredits.Text = "0";
           }

           date = String.Format(dateTimePicker1.Text,"mm/dd/yyy");
           desc = comboDesc.Text;
           deposit = Convert.ToDecimal(txtInDeposits.Text);
           credit = Convert.ToDecimal(txtInCredits.Text);
          
           if (lblBalance.Text == "")
           {
               lblBalance.Text = "0";
           }
          
           totalBal = newCheckBook.BAL + (deposit - credit);
           newCheckBook.addtoCheck(date, desc, deposit, credit, totalBal);
           sqlCommit.Parameters["@Deposits"].Value = newCheckBook.DEP;
           sqlCommit.Parameters["@Credits"].Value = newCheckBook.CRED;
           sqlCommit.Parameters["@Desc"].Value = newCheckBook.DESC;
           sqlCommit.Parameters["@Date"].Value = newCheckBook.DATE;
           sqlCommit.Parameters["@Balance"].Value = newCheckBook.BAL;
         
           sqlConnectionBook.Open();
           sqlAllGetMyBook.ExecuteNonQuery();
           sqlCommit.ExecuteNonQuery();
           sqlConnectionBook.Close();
       
           txtInCredits.Clear();
           txtInDeposits.Clear();
           dataGridView.Refresh();
           this.checkBookBindingSource.Sort = "idRecord ASC";
           this.checkBookTableAdapter.Fill(this.checkBookDataSet.checkBook);
         
           lblBalance.Text = newCheckBook.BAL.ToString();
          

        
       

       }

       private void refreshToolStripMenuItem_Click_1(object sender, EventArgs e)
       {
           Application.Restart();
       }

       private void lblBalance_Click(object sender, EventArgs e)
       {

       }

       private void informationToolStripMenuItem_Click(object sender, EventArgs e)
       {
           Information info = new Information();
           info.Show();

       }
      
       private void button2_Click(object sender, EventArgs e)
       {

          

          listBox1.Items.Clear();
          listbox2.Items.Clear();
           string[] myMonths = new string[checkBookDataSet.checkBook.Rows.Count];
         
           for (int i = 0; i < myMonths.Length; i++)
           {
               DataRow myData = checkBookDataSet.checkBook[i];
               lblRowCount.Visible = true;
               lblRowCount.Text = myData["Date"].ToString() + " " + "This is the row count  " + checkBookDataSet.checkBook.Rows.Count;
               string[] dates = {myData["Date"].ToString()};
               listBox1.Items.Add(myData["Balance"].ToString() + " This is the balance");
               listbox2.Items.Add(myData["Date"].ToString() + " This is the date");
               int convertMonth;
               if (myData["Date"].ToString().Contains("February"))
               {
                   convertMonth = 2;
               }
               else
               {
                   convertMonth = 99;
               }
               listbox2.Items.Add(convertMonth.ToString() + " this is the numeric value for the month");
               Point graphPt = new Point(convertMonth, Convert.ToInt32(myData["Balance"]));
               listbox2.Items.Add(graphPt + " This is the graph point");
               
              

               //switch (myData["Date"].ToString())
               //{


               //    case myData["Date"].ToString().IndexOf("Febuary"):
               //        myData["Date"].ToString().IndexOf("Febuary");
               //        convertMonth = 2;
               //        break;
               //    case myData["Date"].ToString().IndexOf("march"):
               //        //myData["Date"].ToString().IndexOf("march");
               //        convertMonth = 3;
               //        break;

               //}
              // Point[] ptArr = new Point[]{new Point(convertMonth,Convert.ToInt32(myData["Balance"]))};
               //Point[] ptArr = new Point[]{[checkBookDataSet.checkBook.Rows.Count];
               //ptArr[];
               
               

            
               
           }
           //Graphics draImg = new Graphics();
           //Graphics newImg = 
           //Image img = new Bitmap("earth.gif");
           
           //img.DrawImage(img, 10, 10, 100, 100);
           ////if (OpenFileDialog1.ShowDialog() == DialogResult.OK)
           //{
           //    pictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName);
           //}

       }







   } 
}

/**************************************************************************
 * (C) Copyright 2009 by Bradley Cook - Ion Enterprise *
  *************************************************************************/